package com.monitor.service.impl;

import com.monitor.dao.LocationDao;
import com.monitor.po.Location;
import com.monitor.service.LocationService;
import com.monitor.util.CommenUtil;
import com.monitor.util.Pager;

public class LocationServiceImpl implements LocationService {
	private LocationDao locationDao;

	@Override
	public Pager<Location> getLocationByUid(long uid, int pageSize, int currentPage) throws Exception {
		return locationDao.getLocationByUid(uid, pageSize, currentPage);
	}

	@Override
	public boolean deleteLocation(long uid, long lid) throws Exception {
		return locationDao.deleteLocation(uid, lid) > 0;
	}

	@Override
	public boolean deleteLocation(long uid, String idStr) throws Exception {
		if (CommenUtil.isEmpty(idStr)) {
			return false;
		}
		String[] arr = idStr.split(",");
		long[] ids = new long[arr.length];
		for (int i = 0; i < arr.length; i++) {
			String sid = arr[i];
			long id = Long.parseLong(sid);
			ids[i] = id;
		}
		return locationDao.deleteLocation(uid, ids) > 0;
	}

	public LocationDao getLocationDao() {
		return locationDao;
	}

	public void setLocationDao(LocationDao locationDao) {
		this.locationDao = locationDao;
	}

}
